function case(i,d)
  return function(t) local r=t[i] or d 
    if type(r)=='function' then r=r() end
    return r
end end

x='two'

r=case(x) {
 one=1,
 two=2,
 three=3,
}

case(r,function() print "default" end) {
  [1]=function() print "one" end,
  [2]=function() print "two" end,
  [3]=function() print "three" end,
}
